# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models

from wlmodels.codes.dicts import listed_choice
from wlmodels.codes.fields import CrossForeignCharField
from wlmodels.codes.models import ELBaseModel, ELRegion, EntIdable, ELRegisterTypeTax


# 税务信息的企业基础信息
class ELFinance(EntIdable):
    entid_tax = models.IntegerField('税务专用企业UID', unique=True)
    ENTNAME = models.CharField('纳税人名称', max_length=128, null=True, blank=True, db_index=True)
    id_tax = models.CharField('纳税人识别号', max_length=50, db_index=True)
    entertype_tax = models.CharField('企业类型', max_length=2, choices=(("0", "一般企业"), ("1", "金融企业"), ("2", "事业单位"),), null=True, blank=True)
    region_id_id = CrossForeignCharField('所在区域代码', db_column="region_id", max_length=6, null=True, blank=True)
    registertype_id = CrossForeignCharField('经济类型', db_column="registertype", max_length=3, null=True, blank=True)
    industry_tax = models.CharField('是否工业企业', max_length=2, choices=(("1", "工业企业"), ("2", "其他企业"),), null=True, blank=True)
    economic_type = models.CharField('经济行业分类', max_length=20, null=True, blank=True, help_text="经济行业分类代码，门类-大类-中类-小类")
    incometax_rate = models.FloatField('企业所得税适用税率', null=True, blank=True)
    collection_type = models.CharField('征收类型', max_length=2, choices=(("A", "A"), ("B", "B"),), null=True, blank=True)
    name_contact = models.TextField('联系人名称', null=True, blank=True)
    tel_contact = models.TextField('联系人电话', null=True, blank=True)
    staffnum = models.IntegerField('员工人数', blank=True, null=True)

    class Meta:
        verbose_name = '税务企业基础'
        verbose_name_plural = '税务企业基础'
        db_table = 'tax_company'

    def __unicode__(self):
        if self.ENTNAME:
            return self.ENTNAME
        else:
            return self.id_tax

    def _registertype(self):
        the_registertype = ELRegisterTypeTax.objects.filter(code=self.registertype_id).first()
        if the_registertype:
            return the_registertype
        return ""

    _registertype.short_description = "经济类型"

    registertype = property(_registertype)

    def _region_id(self):
        return ELRegion.get_region(self.region_id_id, m="obj")

    _region_id.short_description = "所在区域"

    region_id = property(_region_id)


# 企业税务财务信息
class ELFinanceTax(EntIdable):
    entid_tax = models.ForeignKey('companyplus.ELFinance', verbose_name='所属企业税务UID', db_column='entid_tax', to_field='entid_tax',
                                  null=True, related_name='tax_year')
    year = models.SmallIntegerField('所属年度', choices=((2012, 2012), (2013, 2013), (2014, 2014), (2015, 2015), (2016, 2016),),
                                    null=True, db_index=True)
    islatest = models.NullBooleanField('是否最新数据', null=True, blank=True, db_index=True)
    profit_loss = models.NullBooleanField('盈利or亏损', null=True, blank=True, db_index=True)
    revenue = models.FloatField('营业收入', null=True, blank=True, db_index=True)
    sales_cost = models.FloatField('营业成本', null=True, blank=True)
    sales_tax = models.FloatField('营业税金及附加信息/核定征收企业经费支出', null=True, blank=True)
    sales_expense = models.FloatField('营业费用/核定征收企业换算收入总额', null=True, blank=True)
    G_expense = models.FloatField('管理费用', null=True, blank=True)
    finance_expense = models.FloatField('财务费用', null=True, blank=True)
    asset_devaluation_losses = models.FloatField('资产减值损失', null=True, blank=True)
    fair_value_change = models.FloatField('公允价值变动收益', null=True, blank=True)
    investment_income = models.FloatField('投资收益', null=True, blank=True)
    operation_profit = models.FloatField('营业利润', null=True, blank=True, db_index=True)
    non_operating_income = models.FloatField('营业外收入', null=True, blank=True)
    non_operating_expense = models.FloatField('营业外支出', null=True, blank=True)
    total_profit = models.FloatField('利润（亏损）总额', null=True, blank=True, db_index=True)
    assets = models.FloatField('资产总额', null=True, blank=True)
    assets_re = models.FloatField('资产总额（矫正后）', null=True, blank=True, db_index=True)
    payrol_expense = models.FloatField('工资薪金支出', null=True, blank=True)
    welfare_expenses = models.FloatField('职工福利费支出', null=True, blank=True)
    education_expenses = models.FloatField('职工教育经费支出', null=True, blank=True)
    union_funds = models.FloatField('工会经费', null=True, blank=True)
    ad_expenses = models.FloatField('广告和业务宣传费支出', null=True, blank=True)
    entertainment_expenses = models.FloatField('业务招待费', null=True, blank=True)
    assets_loss = models.FloatField('财产损失', null=True, blank=True)
    asset_devaluation_allowance = models.FloatField('资产减值准备计提数', null=True, blank=True)
    income_tax_adjuste = models.FloatField('纳税调整后所得', null=True, blank=True)
    income_taxable = models.FloatField('应纳税所得额', null=True, blank=True)
    incometax_taxable = models.FloatField('应纳所得税额', null=True, blank=True)
    incometax_amount = models.FloatField('应纳税额', null=True, blank=True)
    incometax_actual = models.FloatField('实际应纳所得税额', null=True, blank=True)

    class Meta:
        verbose_name = '税务年份详情'
        verbose_name_plural = '税务年份详情'
        db_table = 'tax_year'
        unique_together = ("entid_tax", "year")

    def __unicode__(self):
        return u"%s-%s" % (self.entid, self.year)

    # 同步是否最新数据字段
    def save(self, *args, **kwargs):
        the_tax = ELFinanceTax.objects.filter(entid=self.entid).order_by("-year")
        if self.year == the_tax[0].year:
            self.islatest = True
        else:
            self.islatest = False
        super(ELFinanceTax, self).save(*args, **kwargs)


# 企业财务指标
class ELFinanceIndex(EntIdable):
    entid_tax = models.ForeignKey('companyplus.ELFinance', verbose_name='所属企业税务UID', db_column='entid_tax', to_field='entid_tax',
                                  null=True, related_name='tax_index')
    year = models.SmallIntegerField('所属年度', choices=((2012, 2012), (2013, 2013), (2014, 2014), (2015, 2015), (2016, 2016),),
                                    null=True, db_index=True)
    gross = models.FloatField('毛利率（%）', null=True, blank=True, help_text="（营业收入－营业成本）/ 营业收入")
    profit = models.FloatField('营业利润率（%）', null=True, blank=True, help_text="（净利润 + 财务费用 + 应纳税额）/营业收入")
    profit_net = models.FloatField('净利润率（%）', null=True, blank=True, help_text="净利润/营业收入")
    asset_return = models.FloatField('资产回报率（%）', null=True, blank=True, help_text="净利润/总资产")
    income_increase = models.FloatField('营业收入增长率（%）', null=True, blank=True, help_text="（本期营业收入－上期营业收入）/上期营业收入")
    profit_increase = models.FloatField('营业利润增长率（%）', null=True, blank=True, help_text="（本期营业利润－上期营业利润）/上期营业利润")
    profit_net_increase = models.FloatField('净利润增长率（%）', null=True, blank=True, help_text="（本期净利润－上期净利润）/上期净利润")

    class Meta:
        verbose_name = '企业财务指标'
        verbose_name_plural = '企业财务指标'
        db_table = 'tax_index'
        unique_together = ("entid_tax", "year")

    def __unicode__(self):
        return u"%s-%s的财务指标" % (self.entid, self.year)


# 企业税务财务冲突信息
class ELFinanceDup(ELBaseModel):
    ENTNAME = models.CharField('纳税人名称', max_length=128, null=True, blank=True, db_index=True)
    id_tax = models.CharField('纳税人识别号', max_length=50, db_index=True)
    year = models.SmallIntegerField('所属年度', choices=((2012, 2012), (2013, 2013), (2014, 2014), (2015, 2015), (2016, 2016),),
                                    null=True, db_index=True)
    collection_type = models.CharField('征收类型', max_length=2, choices=(("A", "A"), ("B", "B"),), null=True, blank=True)
    profit_loss = models.NullBooleanField('盈利or亏损', null=True, blank=True)
    revenue = models.FloatField('营业收入', null=True, blank=True)
    sales_cost = models.FloatField('营业成本', null=True, blank=True)
    sales_tax = models.FloatField('营业税金及附加信息', null=True, blank=True)
    sales_expense = models.FloatField('营业费用', null=True, blank=True)
    G_expense = models.FloatField('管理费用', null=True, blank=True)
    finance_expense = models.FloatField('财务费用', null=True, blank=True)
    asset_devaluation_losses = models.FloatField('资产减值损失', null=True, blank=True)
    fair_value_change = models.FloatField('公允价值变动收益', null=True, blank=True)
    investment_income = models.FloatField('投资收益', null=True, blank=True)
    operation_profit = models.FloatField('营业利润', null=True, blank=True)
    non_operating_income = models.FloatField('营业外收入', null=True, blank=True)
    non_operating_expense = models.FloatField('营业外支出', null=True, blank=True)
    total_profit = models.FloatField('利润（亏损）总额', null=True, blank=True)
    assets = models.FloatField('资产总额', null=True, blank=True)
    payrol_expense = models.FloatField('工资薪金支出', null=True, blank=True)
    welfare_expenses = models.FloatField('职工福利费支出', null=True, blank=True)
    education_expenses = models.FloatField('职工教育经费支出', null=True, blank=True)
    union_funds = models.FloatField('工会经费', null=True, blank=True)
    ad_expenses = models.FloatField('广告和业务宣传费支出', null=True, blank=True)
    entertainment_expenses = models.FloatField('业务招待费', null=True, blank=True)
    assets_loss = models.FloatField('财产损失', null=True, blank=True)
    asset_devaluation_allowance = models.FloatField('资产减值准备计提数', null=True, blank=True)
    B_revenue = models.FloatField('核定征收收入总额', null=True, blank=True)
    B_sales_cost = models.FloatField('核定征收成本费用', null=True, blank=True)
    B_sales_tax = models.FloatField('核定征收企业经费支出', null=True, blank=True)
    B_sales_expense = models.FloatField('核定征收企业换算收入总额', null=True, blank=True)
    income_tax_adjuste = models.FloatField('纳税调整后所得', null=True, blank=True)
    income_taxable = models.FloatField('应纳税所得额', null=True, blank=True)
    incometax_taxable = models.FloatField('应纳所得税额', null=True, blank=True)
    incometax_amount = models.FloatField('应纳税额', null=True, blank=True)
    incometax_actual = models.FloatField('实际应纳所得税额', null=True, blank=True)

    class Meta:
        verbose_name = '税务冲突数据'
        verbose_name_plural = '税务冲突数据'
        db_table = 'tax_year_dup'

    def __unicode__(self):
        return u"%s-%s" % (self.ENTNAME, self.year)


#########################################################
############### 海关数据 ##################################
#########################################################

tport_choice = (('1', '进口'), ('2', '出口'))


# 海关的企业基础信息
class ELHGEnt(EntIdable):
    entid_hg = models.CharField('海关单位编码', max_length=12, null=True, blank=True, db_index=True)
    ENTNAME = models.CharField('企业名称', max_length=150, null=True, blank=True, db_index=True)
    nacao_id = models.CharField('组织机构代码', max_length=10, null=True, blank=True)

    class Meta:
        verbose_name = '海关企业基础'
        verbose_name_plural = '海关企业基础'
        db_table = 'hg_company'

    def __unicode__(self):
        if self.ENTNAME:
            return self.ENTNAME
        else:
            return self.entid_hg


# 海关企业详情
class ELHGEntDetail(EntIdable):
    entid_hg = models.CharField('海关单位编码', max_length=12, null=True, blank=True, db_index=True)
    tmonth = models.SmallIntegerField('月份', null=True, blank=True)
    tport = models.CharField('进出口标识', max_length=1, null=True, blank=True, choices=tport_choice)
    scale = models.IntegerField('进出口规模', null=True, blank=True)

    class Meta:
        verbose_name = '进出口年统计'
        verbose_name_plural = '进出口年度统计'
        db_table = 'hg_company_detail'

    def __unicode__(self):
        if self.entid:
            return self.entid.ENTNAME
        else:
            return self.entid_hg


# 海关商品详情
class ELHGEntGoods(EntIdable):
    entid_hg = models.CharField('海关单位编码', max_length=12, null=True, blank=True, db_index=True)
    tyear = models.SmallIntegerField('年份', null=True, blank=True)
    statics = models.TextField('商品分类统计', null=True, blank=True)

    class Meta:
        verbose_name = '进出口商品统计'
        verbose_name_plural = '进出口商品统计'
        db_table = 'hg_company_goods'

    def __unicode__(self):
        if self.entid:
            return self.entid.ENTNAME
        else:
            return self.entid_hg


# 海关商品详情
class ELHGGoodsDetail(EntIdable):
    entid_hg = models.CharField('海关单位编码', max_length=12, null=True, blank=True, db_index=True)
    tmonth = models.SmallIntegerField('月份', null=True, blank=True)
    goods = models.CharField('商品税号', max_length=11, null=True, blank=True, db_index=True)
    tport = models.CharField('进出口标识', max_length=1, null=True, blank=True, choices=tport_choice)
    COUNTRY = models.CharField('国家', max_length=30, null=True, blank=True)
    scale = models.IntegerField('进出口规模', null=True, blank=True)

    class Meta:
        verbose_name = '海关商品详情'
        verbose_name_plural = '海关商品详情'
        db_table = 'hg_goods_detail'

    def __unicode__(self):
        if self.entid:
            return self.entid.ENTNAME
        else:
            return self.entid_hg


# 海关原始数据
class ELHGOrigin(ELBaseModel):
    tmonth = models.SmallIntegerField('月份', null=True, blank=True)
    goods = models.CharField('商品税号', max_length=11, null=True, blank=True)
    goods_name = models.CharField('商品税号名称', max_length=64, null=True, blank=True)
    tport = models.CharField('进出口标识', max_length=10, null=True, blank=True)
    country = models.CharField('国家', max_length=30, null=True, blank=True)
    entid_hg = models.CharField('海关单位编码', max_length=12, null=True, blank=True)
    ENTNAME = models.CharField('单位名称', max_length=150, null=True, blank=True, db_index=True)
    nacao_id = models.CharField('组织机构代码', max_length=10, null=True, blank=True)
    scale = models.IntegerField('进出口规模', null=True, blank=True)

    class Meta:
        verbose_name = '海关原始数据'
        verbose_name_plural = '海关原始数据'
        db_table = 'hg_origin'

    def __unicode__(self):
        return "海关原始数据-%s" % self.id


#########################################################
############### 上市公司数据 ################################
#########################################################

# 上市公司信息子表
class ELListed(EntIdable):
    exchange = models.CharField('交易所', choices=listed_choice, max_length=2, db_index=True, blank=True)
    sname = models.CharField('股票名称', max_length=20, blank=True)
    a_name = models.CharField('A股证券简称', max_length=20, blank=True)
    a_code = models.CharField('A股证券代码', max_length=20, blank=True)
    b_name = models.CharField('B股证券简称', max_length=20, blank=True)
    b_code = models.CharField('B股证券代码', max_length=20, blank=True)
    h_name = models.CharField('H股证券简称', max_length=20, blank=True)
    h_code = models.CharField('H股证券代码', max_length=20, blank=True)
    email = models.CharField('公司电子邮箱', max_length=75, blank=True)
    hangye = models.CharField('所属证监会行业', max_length=100, blank=True)
    account = models.TextField('会计师事务所', blank=True)
    law = models.TextField('法律顾问', blank=True)
    paper = models.TextField('信息披露报纸', blank=True)

    class Meta:
        verbose_name = '上市企业信息'
        verbose_name_plural = '上市企业信息'
        db_table = 'listed_basic'

    def __unicode__(self):
        return u'%s的上市信息' % self.entid


# 资产负载表
class ELListedCombas(EntIdable):
    ACCPER = models.DateField('会计期间', null=True, blank=True, db_index=True)
    STKCD = models.CharField('证券代码', max_length=6, db_index=True)
    TYPREP = models.CharField('报表类型', max_length=20, null=True, blank=True)
    A001101000 = models.DecimalField("货币资金", max_digits=15, decimal_places=2, null=True, blank=True)
    A0D1101101 = models.DecimalField("其中:客户资金存款", max_digits=15, decimal_places=2, null=True, blank=True)
    A0D1102000 = models.DecimalField("结算备付金", max_digits=15, decimal_places=2, null=True, blank=True)
    A0D1102101 = models.DecimalField("其中：客户备付金", max_digits=15, decimal_places=2, null=True, blank=True)
    A0B1103000 = models.DecimalField("现金及存放中央银行款项", max_digits=15, decimal_places=2, null=True, blank=True)
    A0B1104000 = models.DecimalField("存放同业款项", max_digits=15, decimal_places=2, null=True, blank=True)
    A0B1105000 = models.DecimalField("贵金属", max_digits=15, decimal_places=2, null=True, blank=True)
    A0F1106000 = models.DecimalField("拆出资金净额", max_digits=15, decimal_places=2, null=True, blank=True)
    A001107000 = models.DecimalField("交易性金融资产", max_digits=15, decimal_places=2, null=True, blank=True)
    A0F1108000 = models.DecimalField("衍生金融资产", max_digits=15, decimal_places=2, null=True, blank=True)
    A001109000 = models.DecimalField("短期投资净额", max_digits=15, decimal_places=2, null=True, blank=True)
    A001110000 = models.DecimalField("应收票据净额", max_digits=15, decimal_places=2, null=True, blank=True)
    A001111000 = models.DecimalField("应收账款净额", max_digits=15, decimal_places=2, null=True, blank=True)
    A001112000 = models.DecimalField("预付款项净额", max_digits=15, decimal_places=2, null=True, blank=True)
    A0I1113000 = models.DecimalField("应收保费净额", max_digits=15, decimal_places=2, null=True, blank=True)
    A0I1114000 = models.DecimalField("应收分保账款净额", max_digits=15, decimal_places=2, null=True, blank=True)
    A0I1115000 = models.DecimalField("应收代位追偿款净额", max_digits=15, decimal_places=2, null=True, blank=True)
    A0I1116000 = models.DecimalField("应收分保合同准备金净额", max_digits=15, decimal_places=2, null=True, blank=True)
    A0I1116101 = models.DecimalField("其中:应收分保未到期责任准备金 净额", max_digits=15, decimal_places=2, null=True, blank=True)
    A0I1116201 = models.DecimalField("其中:应收分保未决赔款准备金净 额 ", max_digits=15, decimal_places=2, null=True, blank=True)
    A0I1116301 = models.DecimalField("其中:应收分保寿险责任准备金净 额", max_digits=15, decimal_places=2, null=True, blank=True)
    A0I1116401 = models.DecimalField("其中:应收分保长期健康险责任准 备金净额", max_digits=15, decimal_places=2, null=True, blank=True)
    A001119000 = models.DecimalField("应收利息净额", max_digits=15, decimal_places=2, null=True, blank=True)
    A001120000 = models.DecimalField("应收股利净额", max_digits=15, decimal_places=2, null=True, blank=True)
    A001121000 = models.DecimalField("其他应收款净额", max_digits=15, decimal_places=2, null=True, blank=True)
    A0F1122000 = models.DecimalField("买入返售金融资产净额", max_digits=15, decimal_places=2, null=True, blank=True)
    A001123000 = models.DecimalField("存货净额", max_digits=15, decimal_places=2, null=True, blank=True)
    A001124000 = models.DecimalField("一年内到期的非流动资产", max_digits=15, decimal_places=2, null=True, blank=True)
    A0D1126000 = models.DecimalField("存出保证金", max_digits=15, decimal_places=2, null=True, blank=True)
    A001125000 = models.DecimalField("其他流动资产", max_digits=15, decimal_places=2, null=True, blank=True)
    A001100000 = models.DecimalField("流动资产合计", max_digits=15, decimal_places=2, null=True, blank=True)
    A0I1224000 = models.DecimalField("保户质押贷款净额", max_digits=15, decimal_places=2, null=True, blank=True)
    A0I1225000 = models.DecimalField("定期存款", max_digits=15, decimal_places=2, null=True, blank=True)
    A0B1201000 = models.DecimalField("发放贷款及垫款净额", max_digits=15, decimal_places=2, null=True, blank=True)
    A001202000 = models.DecimalField("可供出售金融资产净额", max_digits=15, decimal_places=2, null=True, blank=True)
    A001203000 = models.DecimalField("持有至到期投资净额", max_digits=15, decimal_places=2, null=True, blank=True)
    A001204000 = models.DecimalField("长期应收款净额", max_digits=15, decimal_places=2, null=True, blank=True)
    A001205000 = models.DecimalField("长期股权投资净额", max_digits=15, decimal_places=2, null=True, blank=True)
    A001206000 = models.DecimalField("长期债权投资净额", max_digits=15, decimal_places=2, null=True, blank=True)
    A001207000 = models.DecimalField("长期投资净额", max_digits=15, decimal_places=2, null=True, blank=True)
    A0I1209000 = models.DecimalField("存出资本保证金", max_digits=15, decimal_places=2, null=True, blank=True)
    A0I1210000 = models.DecimalField("独立账户资产", max_digits=15, decimal_places=2, null=True, blank=True)
    A001211000 = models.DecimalField("投资性房地产净额", max_digits=15, decimal_places=2, null=True, blank=True)
    A001212000 = models.DecimalField("固定资产净额", max_digits=15, decimal_places=2, null=True, blank=True)
    A001213000 = models.DecimalField("在建工程净额", max_digits=15, decimal_places=2, null=True, blank=True)
    A001214000 = models.DecimalField("工程物资", max_digits=15, decimal_places=2, null=True, blank=True)
    A001215000 = models.DecimalField("固定资产清理", max_digits=15, decimal_places=2, null=True, blank=True)
    A001216000 = models.DecimalField("生产性生物资产净额", max_digits=15, decimal_places=2, null=True, blank=True)
    A001217000 = models.DecimalField("油气资产净额", max_digits=15, decimal_places=2, null=True, blank=True)
    A001218000 = models.DecimalField("无形资产净额", max_digits=15, decimal_places=2, null=True, blank=True)
    A0D1218101 = models.DecimalField("其中:交易席位费", max_digits=15, decimal_places=2, null=True, blank=True)
    A001219000 = models.DecimalField("开发支出", max_digits=15, decimal_places=2, null=True, blank=True)
    A001220000 = models.DecimalField("商誉净额", max_digits=15, decimal_places=2, null=True, blank=True)
    A001221000 = models.DecimalField("长期待摊费用", max_digits=15, decimal_places=2, null=True, blank=True)
    A001222000 = models.DecimalField("递延所得税资产", max_digits=15, decimal_places=2, null=True, blank=True)
    A001223000 = models.DecimalField("其他非流动资产", max_digits=15, decimal_places=2, null=True, blank=True)
    A001200000 = models.DecimalField("非流动资产合计", max_digits=15, decimal_places=2, null=True, blank=True)
    A0F1300000 = models.DecimalField("其他资产", max_digits=15, decimal_places=2, null=True, blank=True)
    A001000000 = models.DecimalField("资产总计", max_digits=15, decimal_places=2, null=True, blank=True)
    A002101000 = models.DecimalField("短期借款", max_digits=15, decimal_places=2, null=True, blank=True)
    A0D2101101 = models.DecimalField("其中:质押借款", max_digits=15, decimal_places=2, null=True, blank=True)
    A0B2102000 = models.DecimalField("向中央银行借款", max_digits=15, decimal_places=2, null=True, blank=True)
    A0B2103000 = models.DecimalField("吸收存款及同业存放", max_digits=15, decimal_places=2, null=True, blank=True)
    A0B2103101 = models.DecimalField("其中：同业及其他金融机构存放款 项 ", max_digits=15, decimal_places=2, null=True, blank=True)
    A0B2103201 = models.DecimalField("其中：吸收存款", max_digits=15, decimal_places=2, null=True, blank=True)
    A0F2104000 = models.DecimalField("拆入资金", max_digits=15, decimal_places=2, null=True, blank=True)
    A002105000 = models.DecimalField("交易性金融负债", max_digits=15, decimal_places=2, null=True, blank=True)
    A0F2106000 = models.DecimalField("衍生金融负债", max_digits=15, decimal_places=2, null=True, blank=True)
    A002107000 = models.DecimalField("应付票据", max_digits=15, decimal_places=2, null=True, blank=True)
    A002108000 = models.DecimalField("应付账款", max_digits=15, decimal_places=2, null=True, blank=True)
    A002109000 = models.DecimalField("预收款项", max_digits=15, decimal_places=2, null=True, blank=True)
    A0F2110000 = models.DecimalField("卖出回购金融资产款", max_digits=15, decimal_places=2, null=True, blank=True)
    A0I2111000 = models.DecimalField("应付手续费及佣金", max_digits=15, decimal_places=2, null=True, blank=True)
    A002112000 = models.DecimalField("应付职工薪酬", max_digits=15, decimal_places=2, null=True, blank=True)
    A002113000 = models.DecimalField("应交税费", max_digits=15, decimal_places=2, null=True, blank=True)
    A002114000 = models.DecimalField("应付利息", max_digits=15, decimal_places=2, null=True, blank=True)
    A002115000 = models.DecimalField("应付股利", max_digits=15, decimal_places=2, null=True, blank=True)
    A0I2116000 = models.DecimalField("应付赔付款", max_digits=15, decimal_places=2, null=True, blank=True)
    A0I2117000 = models.DecimalField("应付保单红利", max_digits=15, decimal_places=2, null=True, blank=True)
    A0I2118000 = models.DecimalField("保户储金及投资款", max_digits=15, decimal_places=2, null=True, blank=True)
    A0I2119000 = models.DecimalField("保险合同准备金", max_digits=15, decimal_places=2, null=True, blank=True)
    A0I2119101 = models.DecimalField("其中:未到期责任准备金", max_digits=15, decimal_places=2, null=True, blank=True)
    A0I2119201 = models.DecimalField("其中:未决赔款准备金", max_digits=15, decimal_places=2, null=True, blank=True)
    A0I2119301 = models.DecimalField("其中:寿险责任准备金", max_digits=15, decimal_places=2, null=True, blank=True)
    A0I2119401 = models.DecimalField("其中:长期健康险责任准备金", max_digits=15, decimal_places=2, null=True, blank=True)
    A002120000 = models.DecimalField("其他应付款", max_digits=15, decimal_places=2, null=True, blank=True)
    A0I2121000 = models.DecimalField("应付分保账款", max_digits=15, decimal_places=2, null=True, blank=True)
    A0D2122000 = models.DecimalField("代理买卖证券款", max_digits=15, decimal_places=2, null=True, blank=True)
    A0D2123000 = models.DecimalField("代理承销证券款", max_digits=15, decimal_places=2, null=True, blank=True)
    A0I2124000 = models.DecimalField("预收保费", max_digits=15, decimal_places=2, null=True, blank=True)
    A002125000 = models.DecimalField("一年内到期的非流动负债", max_digits=15, decimal_places=2, null=True, blank=True)
    A002126000 = models.DecimalField("其他流动负债", max_digits=15, decimal_places=2, null=True, blank=True)
    A002100000 = models.DecimalField("流动负债合计", max_digits=15, decimal_places=2, null=True, blank=True)
    A002201000 = models.DecimalField("长期借款", max_digits=15, decimal_places=2, null=True, blank=True)
    A0D2202000 = models.DecimalField("独立账户负债", max_digits=15, decimal_places=2, null=True, blank=True)
    A002203000 = models.DecimalField("应付债券", max_digits=15, decimal_places=2, null=True, blank=True)
    A002204000 = models.DecimalField("长期应付款", max_digits=15, decimal_places=2, null=True, blank=True)
    A002205000 = models.DecimalField("专项应付款", max_digits=15, decimal_places=2, null=True, blank=True)
    A002206000 = models.DecimalField("长期负债合计", max_digits=15, decimal_places=2, null=True, blank=True)
    A002207000 = models.DecimalField("预计负债", max_digits=15, decimal_places=2, null=True, blank=True)
    A002208000 = models.DecimalField("递延所得税负债", max_digits=15, decimal_places=2, null=True, blank=True)
    A002209000 = models.DecimalField("其他非流动负债", max_digits=15, decimal_places=2, null=True, blank=True)
    A002200000 = models.DecimalField("非流动负债合计", max_digits=15, decimal_places=2, null=True, blank=True)
    A0F2300000 = models.DecimalField("其他负债", max_digits=15, decimal_places=2, null=True, blank=True)
    A002000000 = models.DecimalField("负债合计", max_digits=15, decimal_places=2, null=True, blank=True)
    A003101000 = models.DecimalField("实收资本(或股本)", max_digits=15, decimal_places=2, null=True, blank=True)
    A003102000 = models.DecimalField("资本公积", max_digits=15, decimal_places=2, null=True, blank=True)
    A003102101 = models.DecimalField("其中：库存股", max_digits=15, decimal_places=2, null=True, blank=True)
    A003103000 = models.DecimalField("盈余公积", max_digits=15, decimal_places=2, null=True, blank=True)
    A0F3104000 = models.DecimalField("一般风险准备", max_digits=15, decimal_places=2, null=True, blank=True)
    A003105000 = models.DecimalField("未分配利润", max_digits=15, decimal_places=2, null=True, blank=True)
    A003106000 = models.DecimalField("外币报表折算差额", max_digits=15, decimal_places=2, null=True, blank=True)
    A003107000 = models.DecimalField("未确认的投资损失", max_digits=15, decimal_places=2, null=True, blank=True)
    A0F3108000 = models.DecimalField("A0F3108000", max_digits=15, decimal_places=2, null=True, blank=True)
    A0F3109000 = models.DecimalField("A0F3109000", max_digits=15, decimal_places=2, null=True, blank=True)
    A003100000 = models.DecimalField("归属于母公司所有者权益合计", max_digits=15, decimal_places=2, null=True, blank=True)
    A003200000 = models.DecimalField("少数股东权益", max_digits=15, decimal_places=2, null=True, blank=True)
    A003000000 = models.DecimalField("所有者权益合计", max_digits=15, decimal_places=2, null=True, blank=True)
    A004000000 = models.DecimalField("负债与所有者权益总计", max_digits=15, decimal_places=2, null=True, blank=True)

    class Meta:
        verbose_name = '资产负载表'
        verbose_name_plural = '资产负载表'
        db_table = 'listed_combas'

    def __unicode__(self):
        return u'%s的资产负载' % self.entid


# 利润表
class ELListedComins(EntIdable):
    ACCPER = models.DateField('会计期间', null=True, blank=True, db_index=True)
    STKCD = models.CharField('证券代码', max_length=6, db_index=True)
    TYPREP = models.CharField('报表类型', max_length=20, null=True, blank=True)
    B001100000 = models.DecimalField("营业总收入", max_digits=15, decimal_places=2, null=True, blank=True)
    B001101000 = models.DecimalField("营业收入", max_digits=15, decimal_places=2, null=True, blank=True)
    BBD1102000 = models.DecimalField("利息净收入", max_digits=15, decimal_places=2, null=True, blank=True)
    BBD1102101 = models.DecimalField("利息收入", max_digits=15, decimal_places=2, null=True, blank=True)
    BBD1102203 = models.DecimalField("利息支出 ", max_digits=15, decimal_places=2, null=True, blank=True)
    B0I1103000 = models.DecimalField("已赚保费", max_digits=15, decimal_places=2, null=True, blank=True)
    B0I1103101 = models.DecimalField("保险业务收入", max_digits=15, decimal_places=2, null=True, blank=True)
    B0I1103111 = models.DecimalField("其中：分保费收入", max_digits=15, decimal_places=2, null=True, blank=True)
    B0I1103203 = models.DecimalField("减：分出保费", max_digits=15, decimal_places=2, null=True, blank=True)
    B0I1103303 = models.DecimalField("减：提取未到期责任准备金", max_digits=15, decimal_places=2, null=True, blank=True)
    B0D1104000 = models.DecimalField("手续费及佣金净收入", max_digits=15, decimal_places=2, null=True, blank=True)
    B0D1104101 = models.DecimalField("其中：代理买卖证券业务净收入", max_digits=15, decimal_places=2, null=True, blank=True)
    B0D1104201 = models.DecimalField("其中:证券承销业务净收入", max_digits=15, decimal_places=2, null=True, blank=True)
    B0D1104301 = models.DecimalField("其中：受托客户资产管理业务净收 入", max_digits=15, decimal_places=2, null=True, blank=True)
    B0D1104401 = models.DecimalField("手续费及佣金收入", max_digits=15, decimal_places=2, null=True, blank=True)
    B0D1104501 = models.DecimalField("手续费及佣金支出", max_digits=15, decimal_places=2, null=True, blank=True)
    B0F1105000 = models.DecimalField("其他业务收入", max_digits=15, decimal_places=2, null=True, blank=True)
    B001200000 = models.DecimalField("营业总成本", max_digits=15, decimal_places=2, null=True, blank=True)
    B001201000 = models.DecimalField("营业成本", max_digits=15, decimal_places=2, null=True, blank=True)
    B0I1202000 = models.DecimalField("退保金", max_digits=15, decimal_places=2, null=True, blank=True)
    B0I1203000 = models.DecimalField("赔付支出净额", max_digits=15, decimal_places=2, null=True, blank=True)
    B0I1203101 = models.DecimalField("赔付支出", max_digits=15, decimal_places=2, null=True, blank=True)
    B0I1203203 = models.DecimalField("减：摊回赔付支出", max_digits=15, decimal_places=2, null=True, blank=True)
    B0I1204000 = models.DecimalField("提取保险责任准备金净额", max_digits=15, decimal_places=2, null=True, blank=True)
    B0I1204101 = models.DecimalField("提取保险责任准备金", max_digits=15, decimal_places=2, null=True, blank=True)
    B0I1204203 = models.DecimalField("减：摊回保险责任准备金", max_digits=15, decimal_places=2, null=True, blank=True)
    B0I1205000 = models.DecimalField("保单红利支出", max_digits=15, decimal_places=2, null=True, blank=True)
    B0I1206000 = models.DecimalField("分保费用", max_digits=15, decimal_places=2, null=True, blank=True)
    B001207000 = models.DecimalField("营业税金及附加", max_digits=15, decimal_places=2, null=True, blank=True)
    B0F1208000 = models.DecimalField("业务及管理费", max_digits=15, decimal_places=2, null=True, blank=True)
    B0I1208103 = models.DecimalField("减：摊回分保费用", max_digits=15, decimal_places=2, null=True, blank=True)
    B001209000 = models.DecimalField("销售费用", max_digits=15, decimal_places=2, null=True, blank=True)
    B001210000 = models.DecimalField("管理费用", max_digits=15, decimal_places=2, null=True, blank=True)
    B001211000 = models.DecimalField("财务费用", max_digits=15, decimal_places=2, null=True, blank=True)
    B001212000 = models.DecimalField("资产减值损失", max_digits=15, decimal_places=2, null=True, blank=True)
    B0F1213000 = models.DecimalField("其他业务成本", max_digits=15, decimal_places=2, null=True, blank=True)
    B001301000 = models.DecimalField("公允价值变动收益", max_digits=15, decimal_places=2, null=True, blank=True)
    B001302000 = models.DecimalField("投资收益", max_digits=15, decimal_places=2, null=True, blank=True)
    B001302101 = models.DecimalField("其中：对联营企业和合营企业的投资收益 ", max_digits=15, decimal_places=2, null=True, blank=True)
    B001303000 = models.DecimalField("汇兑收益", max_digits=15, decimal_places=2, null=True, blank=True)
    B001304000 = models.DecimalField("其他业务利润", max_digits=15, decimal_places=2, null=True, blank=True)
    B001300000 = models.DecimalField("营业利润", max_digits=15, decimal_places=2, null=True, blank=True)
    B001400000 = models.DecimalField("营业外收入", max_digits=15, decimal_places=2, null=True, blank=True)
    B001500000 = models.DecimalField("营业外支出", max_digits=15, decimal_places=2, null=True, blank=True)
    B001500101 = models.DecimalField("其中：非流动资产处置净损益", max_digits=15, decimal_places=2, null=True, blank=True)
    B001000000 = models.DecimalField("利润总额", max_digits=15, decimal_places=2, null=True, blank=True)
    B002100000 = models.DecimalField("所得税费用", max_digits=15, decimal_places=2, null=True, blank=True)
    B002200000 = models.DecimalField("未确认的投资损失", max_digits=15, decimal_places=2, null=True, blank=True)
    B002300000 = models.DecimalField("影响净利润的其他项目", max_digits=15, decimal_places=2, null=True, blank=True)
    B002000000 = models.DecimalField("净利润", max_digits=15, decimal_places=2, null=True, blank=True)
    B002000101 = models.DecimalField("归属于母公司所有者的净利润", max_digits=15, decimal_places=2, null=True, blank=True)
    B002000201 = models.DecimalField("少数股东损益", max_digits=15, decimal_places=2, null=True, blank=True)
    B003000000 = models.DecimalField("基本每股收益", max_digits=15, decimal_places=2, null=True, blank=True)
    B004000000 = models.DecimalField("稀释每股收益", max_digits=15, decimal_places=2, null=True, blank=True)
    B005000000 = models.DecimalField("其他综合收益(损失)", max_digits=15, decimal_places=2, null=True, blank=True)
    B006000000 = models.DecimalField("综合收益总额", max_digits=15, decimal_places=2, null=True, blank=True)
    B006000101 = models.DecimalField("归属于母公司所有者的综合收益", max_digits=15, decimal_places=2, null=True, blank=True)
    B006000102 = models.DecimalField("归属少数股东的综合收益", max_digits=15, decimal_places=2, null=True, blank=True)

    class Meta:
        verbose_name = '利润表'
        verbose_name_plural = '利润表'
        db_table = 'listed_comins'

    def __unicode__(self):
        return u'%s的利润表' % self.entid


# 现金流量表直接法
class ELListedComscfd(EntIdable):
    ACCPER = models.DateField('会计期间', null=True, blank=True, db_index=True)
    STKCD = models.CharField('证券代码', max_length=6, db_index=True)
    TYPREP = models.CharField('报表类型', max_length=20, null=True, blank=True)
    C001001000 = models.DecimalField("销售商品、提供劳务收到的现金 ", max_digits=15, decimal_places=5, null=True, blank=True)
    C0B1002000 = models.DecimalField("客户存款和同业存放款项净增加额", max_digits=15, decimal_places=5, null=True, blank=True)
    C0B1003000 = models.DecimalField("向中央银行借款净增加额", max_digits=15, decimal_places=5, null=True, blank=True)
    C0B1004000 = models.DecimalField("向其他金融机构拆入资金净增加额", max_digits=15, decimal_places=5, null=True, blank=True)
    C0I1005000 = models.DecimalField("收到原保险合同保费取得的现金", max_digits=15, decimal_places=5, null=True, blank=True)
    C0I1006000 = models.DecimalField("收到再保险业务现金净额", max_digits=15, decimal_places=5, null=True, blank=True)
    C0I1007000 = models.DecimalField("保户储金及投资款净增加额", max_digits=15, decimal_places=5, null=True, blank=True)
    C0D1008000 = models.DecimalField("处置交易性金融资产净增加额", max_digits=15, decimal_places=5, null=True, blank=True)
    C0F1009000 = models.DecimalField("收取利息、手续费及佣金的现金", max_digits=15, decimal_places=5, null=True, blank=True)
    C0D1010000 = models.DecimalField("拆入资金净增加额", max_digits=15, decimal_places=5, null=True, blank=True)
    C0D1011000 = models.DecimalField("回购业务资金净增加额", max_digits=15, decimal_places=5, null=True, blank=True)
    C001012000 = models.DecimalField("收到的税费返还", max_digits=15, decimal_places=5, null=True, blank=True)
    C001013000 = models.DecimalField("收到的其他与经营活动有关的现金", max_digits=15, decimal_places=5, null=True, blank=True)
    C001014000 = models.DecimalField("购买商品、接受劳务支付的现金", max_digits=15, decimal_places=5, null=True, blank=True)
    C0B1015000 = models.DecimalField("客户贷款及垫款净增加额", max_digits=15, decimal_places=5, null=True, blank=True)
    C0B1016000 = models.DecimalField("存放中央银行和同业款项净增加额", max_digits=15, decimal_places=5, null=True, blank=True)
    C0I1017000 = models.DecimalField("支付原保险合同赔付款项的现金", max_digits=15, decimal_places=5, null=True, blank=True)
    C0F1018000 = models.DecimalField("支付利息、手续费及佣金的现金", max_digits=15, decimal_places=5, null=True, blank=True)
    C0I1019000 = models.DecimalField("支付保单红利的现金", max_digits=15, decimal_places=5, null=True, blank=True)
    C001020000 = models.DecimalField("支付给职工以及为职工支付的现金", max_digits=15, decimal_places=5, null=True, blank=True)
    C001021000 = models.DecimalField("支付的各项税费", max_digits=15, decimal_places=5, null=True, blank=True)
    C001022000 = models.DecimalField("支付其他与经营活动有关的现金", max_digits=15, decimal_places=5, null=True, blank=True)
    C001000000 = models.DecimalField("经营活动产生的现金流量净额", max_digits=15, decimal_places=5, null=True, blank=True)
    C002001000 = models.DecimalField("收回投资收到的现金", max_digits=15, decimal_places=5, null=True, blank=True)
    C002002000 = models.DecimalField("取得投资收益收到的现金", max_digits=15, decimal_places=5, null=True, blank=True)
    C002003000 = models.DecimalField("处置固定资产、无形资产和其他长 期资产收回的现金净额 ", max_digits=15, decimal_places=5, null=True, blank=True)
    C002004000 = models.DecimalField("处置子公司及其他营业单位收到的 现金净额", max_digits=15, decimal_places=5, null=True, blank=True)
    C002005000 = models.DecimalField("收到的其他与投资活动有关的现金", max_digits=15, decimal_places=5, null=True, blank=True)
    C002006000 = models.DecimalField("购建固定资产、无形资产和其他长 期资产支付的现金", max_digits=15, decimal_places=5, null=True, blank=True)
    C002007000 = models.DecimalField("投资支付的现金", max_digits=15, decimal_places=5, null=True, blank=True)
    C0I2008000 = models.DecimalField("质押贷款净增加额", max_digits=15, decimal_places=5, null=True, blank=True)
    C002009000 = models.DecimalField("取得子公司及其他营业单位支付的 现金净额 ", max_digits=15, decimal_places=5, null=True, blank=True)
    C002010000 = models.DecimalField("支付其他与投资活动有关的现金", max_digits=15, decimal_places=5, null=True, blank=True)
    C002000000 = models.DecimalField("投资活动产生的现金流量净额", max_digits=15, decimal_places=5, null=True, blank=True)
    C003008000 = models.DecimalField("吸收投资收到的现金", max_digits=15, decimal_places=5, null=True, blank=True)
    C003001000 = models.DecimalField("吸收权益性投资收到的现金", max_digits=15, decimal_places=5, null=True, blank=True)
    C003001101 = models.DecimalField("其中：子公司吸收少数股东投资 收到的现金", max_digits=15, decimal_places=5, null=True, blank=True)
    C003003000 = models.DecimalField("发行债券收到的现金", max_digits=15, decimal_places=5, null=True, blank=True)
    C003002000 = models.DecimalField("取得借款收到的现金", max_digits=15, decimal_places=5, null=True, blank=True)
    C003004000 = models.DecimalField("收到其他与筹资活动有关的现金", max_digits=15, decimal_places=5, null=True, blank=True)
    C003005000 = models.DecimalField("偿还债务支付的现金", max_digits=15, decimal_places=5, null=True, blank=True)
    C003006000 = models.DecimalField("分配股利、利润或偿付利息支付的 现金", max_digits=15, decimal_places=5, null=True, blank=True)
    C003006101 = models.DecimalField("其中：子公司支付给少数股东的 股利、利润", max_digits=15, decimal_places=5, null=True, blank=True)
    C003007000 = models.DecimalField("支付其他与筹资活动有关的现金", max_digits=15, decimal_places=5, null=True, blank=True)
    C003000000 = models.DecimalField("筹资活动产生的现金流量净额", max_digits=15, decimal_places=5, null=True, blank=True)
    C004000000 = models.DecimalField("汇率变动对现金及现金等价物的影响", max_digits=15, decimal_places=5, null=True, blank=True)
    C007000000 = models.DecimalField("其他对现金的影响", max_digits=15, decimal_places=5, null=True, blank=True)
    C005000000 = models.DecimalField("现金及现金等价物净增加额", max_digits=15, decimal_places=5, null=True, blank=True)
    C005001000 = models.DecimalField("期初现金及现金等价物余额", max_digits=15, decimal_places=5, null=True, blank=True)
    C006000000 = models.DecimalField("期末现金及现金等价物余额", max_digits=15, decimal_places=5, null=True, blank=True)

    class Meta:
        verbose_name = '现金流量表直接法'
        verbose_name_plural = '现金流量表直接法'
        db_table = 'listed_comscfd'

    def __unicode__(self):
        return u'%s的现金流量表直接法' % self.entid


# 现金流量表间接法
class ELListedComscfi(EntIdable):
    ACCPER = models.DateField('会计期间', null=True, blank=True, db_index=True)
    STKCD = models.CharField('证券代码', max_length=6, db_index=True)
    TYPREP = models.CharField('报表类型', max_length=20, null=True, blank=True)
    D000101000 = models.DecimalField("净利润", max_digits=15, decimal_places=5, null=True, blank=True)
    D000117000 = models.DecimalField("未确认的投资损失", max_digits=15, decimal_places=5, null=True, blank=True)
    D000102000 = models.DecimalField("资产减值准备", max_digits=15, decimal_places=5, null=True, blank=True)
    D000103000 = models.DecimalField("固定资产折旧、油气资产折耗、生 产性生物资产折旧", max_digits=15, decimal_places=5, null=True, blank=True)
    D000104000 = models.DecimalField("无形资产摊销", max_digits=15, decimal_places=5, null=True, blank=True)
    D000105000 = models.DecimalField("长期待摊费用摊销", max_digits=15, decimal_places=5, null=True, blank=True)
    D000106000 = models.DecimalField("处置固定资产、无形资产和其他长 期资产的损失(收益以“－”号填列）", max_digits=15, decimal_places=5, null=True, blank=True)
    D000107000 = models.DecimalField("固定资产报废损失(收益以“－”号 填列）", max_digits=15, decimal_places=5, null=True, blank=True)
    D000108000 = models.DecimalField("公允价值变动损失(收益以“－”号 填列） ", max_digits=15, decimal_places=5, null=True, blank=True)
    D000109000 = models.DecimalField("财务费用(收益以“－”号填列）", max_digits=15, decimal_places=5, null=True, blank=True)
    D000110000 = models.DecimalField("投资损失(收益以“－”号填列）", max_digits=15, decimal_places=5, null=True, blank=True)
    D000111000 = models.DecimalField("递延所得税资产减少（增加以“－” 号填列）", max_digits=15, decimal_places=5, null=True, blank=True)
    D000112000 = models.DecimalField("递延所得税负债增加（减少以“－” 号填列）", max_digits=15, decimal_places=5, null=True, blank=True)
    D000113000 = models.DecimalField("存货的减少（增加以“－”号填列）", max_digits=15, decimal_places=5, null=True, blank=True)
    D000114000 = models.DecimalField("经营性应收项目的减少（增加以 “－”号填列）", max_digits=15, decimal_places=5, null=True, blank=True)
    D000115000 = models.DecimalField("经营性应付项目的增加（减少以 “－”号填列）", max_digits=15, decimal_places=5, null=True, blank=True)
    D000116000 = models.DecimalField("其他", max_digits=15, decimal_places=5, null=True, blank=True)
    D000100000 = models.DecimalField("经营活动产生的现金流量净额", max_digits=15, decimal_places=5, null=True, blank=True)
    D000201000 = models.DecimalField("债务转为资本", max_digits=15, decimal_places=5, null=True, blank=True)
    D000202000 = models.DecimalField("一年内到期的可转换公司债券", max_digits=15, decimal_places=5, null=True, blank=True)
    D000203000 = models.DecimalField("融资租赁固定资产", max_digits=15, decimal_places=5, null=True, blank=True)
    D000204000 = models.DecimalField("现金的期末余额", max_digits=15, decimal_places=5, null=True, blank=True)
    D000205000 = models.DecimalField("现金的期初余额", max_digits=15, decimal_places=5, null=True, blank=True)
    D000206000 = models.DecimalField("现金等价物的期末余额", max_digits=15, decimal_places=5, null=True, blank=True)
    D000207000 = models.DecimalField("现金等价物的期初余额", max_digits=15, decimal_places=5, null=True, blank=True)
    D000200000 = models.DecimalField("现金及现金等价物净增加额", max_digits=15, decimal_places=5, null=True, blank=True)

    class Meta:
        verbose_name = '现金流量表间接法'
        verbose_name_plural = '现金流量表间接法'
        db_table = 'listed_comscfi'

    def __unicode__(self):
        return u'%s的现金流量表间接法' % self.entid


# 新三板财务信息
class ELListedXinsan(EntIdable):
    ENTNAME = models.CharField('公司中文名称', max_length=100, null=True, blank=True, db_index=True)
    year = models.SmallIntegerField('年份', null=True)
    zd0 = models.CharField('证券代码', max_length=20, db_index=True)
    zd1 = models.CharField('证券简称', max_length=30, null=True, blank=True, db_index=True)
    zd3 = models.DecimalField('货币资金', max_digits=15, decimal_places=5, null=True, blank=True)
    zd4 = models.DecimalField('交易性金融资产', max_digits=15, decimal_places=5, null=True, blank=True)
    zd5 = models.DecimalField('应收票据', max_digits=15, decimal_places=5, null=True, blank=True)
    zd6 = models.DecimalField('应收账款', max_digits=15, decimal_places=5, null=True, blank=True)
    zd7 = models.DecimalField('其他应收款', max_digits=15, decimal_places=5, null=True, blank=True)
    zd8 = models.DecimalField('预付账款', max_digits=15, decimal_places=5, null=True, blank=True)
    zd9 = models.DecimalField('应收股利', max_digits=15, decimal_places=5, null=True, blank=True)
    zd10 = models.DecimalField('应收利息', max_digits=15, decimal_places=5, null=True, blank=True)
    zd11 = models.DecimalField('存货', max_digits=15, decimal_places=5, null=True, blank=True)
    zd12 = models.DecimalField('消耗性生物资产', max_digits=15, decimal_places=5, null=True, blank=True)
    zd13 = models.DecimalField('待摊费用', max_digits=15, decimal_places=5, null=True, blank=True)
    zd14 = models.DecimalField('划分为持有待售的资产', max_digits=15, decimal_places=5, null=True, blank=True)
    zd15 = models.DecimalField('一年内到期的非流动资产', max_digits=15, decimal_places=5, null=True, blank=True)
    zd16 = models.DecimalField('结算备付金', max_digits=15, decimal_places=5, null=True, blank=True)
    zd17 = models.DecimalField('拆出资金', max_digits=15, decimal_places=5, null=True, blank=True)
    zd18 = models.DecimalField('应收保费', max_digits=15, decimal_places=5, null=True, blank=True)
    zd19 = models.DecimalField('应收分保账款', max_digits=15, decimal_places=5, null=True, blank=True)
    zd20 = models.DecimalField('应收分保合同准备金', max_digits=15, decimal_places=5, null=True, blank=True)
    zd21 = models.DecimalField('买入返售金融资产', max_digits=15, decimal_places=5, null=True, blank=True)
    zd22 = models.DecimalField('其他流动资产', max_digits=15, decimal_places=5, null=True, blank=True)
    zd23 = models.DecimalField('流动资产合计', max_digits=15, decimal_places=5, null=True, blank=True)
    zd24 = models.DecimalField('可供出售金融资产', max_digits=15, decimal_places=5, null=True, blank=True)
    zd25 = models.DecimalField('持有至到期投资', max_digits=15, decimal_places=5, null=True, blank=True)
    zd26 = models.DecimalField('投资性房地产', max_digits=15, decimal_places=5, null=True, blank=True)
    zd27 = models.DecimalField('长期股权投资', max_digits=15, decimal_places=5, null=True, blank=True)
    zd28 = models.DecimalField('长期应收款', max_digits=15, decimal_places=5, null=True, blank=True)
    zd29 = models.DecimalField('固定资产', max_digits=15, decimal_places=5, null=True, blank=True)
    zd30 = models.DecimalField('工程物资', max_digits=15, decimal_places=5, null=True, blank=True)
    zd31 = models.DecimalField('在建工程', max_digits=15, decimal_places=5, null=True, blank=True)
    zd32 = models.DecimalField('固定资产清理', max_digits=15, decimal_places=5, null=True, blank=True)
    zd33 = models.DecimalField('生产性生物资产', max_digits=15, decimal_places=5, null=True, blank=True)
    zd34 = models.DecimalField('油气资产', max_digits=15, decimal_places=5, null=True, blank=True)
    zd35 = models.DecimalField('无形资产', max_digits=15, decimal_places=5, null=True, blank=True)
    zd36 = models.DecimalField('开发支出', max_digits=15, decimal_places=5, null=True, blank=True)
    zd37 = models.DecimalField('商誉', max_digits=15, decimal_places=5, null=True, blank=True)
    zd38 = models.DecimalField('长期待摊费用', max_digits=15, decimal_places=5, null=True, blank=True)
    zd39 = models.DecimalField('递延所得税资产', max_digits=15, decimal_places=5, null=True, blank=True)
    zd40 = models.DecimalField('发放贷款及垫款', max_digits=15, decimal_places=5, null=True, blank=True)
    zd41 = models.DecimalField('其他非流动资产', max_digits=15, decimal_places=5, null=True, blank=True)
    zd42 = models.DecimalField('非流动资产合计', max_digits=15, decimal_places=5, null=True, blank=True)
    zd43 = models.DecimalField('资产总计', max_digits=15, decimal_places=5, null=True, blank=True)
    zd44 = models.DecimalField('短期借款', max_digits=15, decimal_places=5, null=True, blank=True)
    zd45 = models.DecimalField('交易性金融负债', max_digits=15, decimal_places=5, null=True, blank=True)
    zd46 = models.DecimalField('应付票据', max_digits=15, decimal_places=5, null=True, blank=True)
    zd47 = models.DecimalField('应付账款', max_digits=15, decimal_places=5, null=True, blank=True)
    zd48 = models.DecimalField('预收账款', max_digits=15, decimal_places=5, null=True, blank=True)
    zd49 = models.DecimalField('应付职工薪酬', max_digits=15, decimal_places=5, null=True, blank=True)
    zd50 = models.DecimalField('应交税费', max_digits=15, decimal_places=5, null=True, blank=True)
    zd51 = models.DecimalField('应付利息', max_digits=15, decimal_places=5, null=True, blank=True)
    zd52 = models.DecimalField('应付股利', max_digits=15, decimal_places=5, null=True, blank=True)
    zd53 = models.DecimalField('其他应付款', max_digits=15, decimal_places=5, null=True, blank=True)
    zd54 = models.DecimalField('预提费用', max_digits=15, decimal_places=5, null=True, blank=True)
    zd55 = models.DecimalField('递延收益-流动负债', max_digits=15, decimal_places=5, null=True, blank=True)
    zd56 = models.DecimalField('划分为持有待售的负债', max_digits=15, decimal_places=5, null=True, blank=True)
    zd57 = models.DecimalField('一年内到期的非流动负债', max_digits=15, decimal_places=5, null=True, blank=True)
    zd58 = models.DecimalField('应付短期债券', max_digits=15, decimal_places=5, null=True, blank=True)
    zd59 = models.DecimalField('向中央银行借款', max_digits=15, decimal_places=5, null=True, blank=True)
    zd60 = models.DecimalField('吸收存款及同业存放', max_digits=15, decimal_places=5, null=True, blank=True)
    zd61 = models.DecimalField('拆入资金', max_digits=15, decimal_places=5, null=True, blank=True)
    zd62 = models.DecimalField('卖出回购金融资产款', max_digits=15, decimal_places=5, null=True, blank=True)
    zd63 = models.DecimalField('应付手续费及佣金', max_digits=15, decimal_places=5, null=True, blank=True)
    zd64 = models.DecimalField('应付分保账款', max_digits=15, decimal_places=5, null=True, blank=True)
    zd65 = models.DecimalField('保险合同准备金', max_digits=15, decimal_places=5, null=True, blank=True)
    zd66 = models.DecimalField('代理买卖证券款', max_digits=15, decimal_places=5, null=True, blank=True)
    zd67 = models.DecimalField('代理承销证券款', max_digits=15, decimal_places=5, null=True, blank=True)
    zd68 = models.DecimalField('其他流动负债', max_digits=15, decimal_places=5, null=True, blank=True)
    zd69 = models.DecimalField('流动负债合计', max_digits=15, decimal_places=5, null=True, blank=True)
    zd70 = models.DecimalField('长期借款', max_digits=15, decimal_places=5, null=True, blank=True)
    zd71 = models.DecimalField('应付债券', max_digits=15, decimal_places=5, null=True, blank=True)
    zd72 = models.DecimalField('长期应付款', max_digits=15, decimal_places=5, null=True, blank=True)
    zd73 = models.DecimalField('长期应付职工薪酬', max_digits=15, decimal_places=5, null=True, blank=True)
    zd74 = models.DecimalField('专项应付款', max_digits=15, decimal_places=5, null=True, blank=True)
    zd75 = models.DecimalField('预计负债', max_digits=15, decimal_places=5, null=True, blank=True)
    zd76 = models.DecimalField('递延所得税负债', max_digits=15, decimal_places=5, null=True, blank=True)
    zd77 = models.DecimalField('递延收益-非流动负债', max_digits=15, decimal_places=5, null=True, blank=True)
    zd78 = models.DecimalField('其他非流动负债', max_digits=15, decimal_places=5, null=True, blank=True)
    zd79 = models.DecimalField('非流动负债合计', max_digits=15, decimal_places=5, null=True, blank=True)
    zd80 = models.DecimalField('负债合计', max_digits=15, decimal_places=5, null=True, blank=True)
    zd81 = models.DecimalField('实收资本(或股本)', max_digits=15, decimal_places=5, null=True, blank=True)
    zd82 = models.DecimalField('其他权益工具', max_digits=15, decimal_places=5, null=True, blank=True)
    zd83 = models.DecimalField('其他权益工具:优先股', max_digits=15, decimal_places=5, null=True, blank=True)
    zd84 = models.DecimalField('资本公积金', max_digits=15, decimal_places=5, null=True, blank=True)
    zd85 = models.DecimalField('盈余公积金', max_digits=15, decimal_places=5, null=True, blank=True)
    zd86 = models.DecimalField('未分配利润', max_digits=15, decimal_places=5, null=True, blank=True)
    zd87 = models.DecimalField('库存股', max_digits=15, decimal_places=5, null=True, blank=True)
    zd88 = models.DecimalField('其他综合收益', max_digits=15, decimal_places=5, null=True, blank=True)
    zd89 = models.DecimalField('专项储备', max_digits=15, decimal_places=5, null=True, blank=True)
    zd90 = models.DecimalField('一般风险准备', max_digits=15, decimal_places=5, null=True, blank=True)
    zd91 = models.DecimalField('外币报表折算差额', max_digits=15, decimal_places=5, null=True, blank=True)
    zd92 = models.DecimalField('未确认的投资损失', max_digits=15, decimal_places=5, null=True, blank=True)
    zd93 = models.DecimalField('少数股东权益', max_digits=15, decimal_places=5, null=True, blank=True)
    zd94 = models.DecimalField('归属母公司股东的权益', max_digits=15, decimal_places=5, null=True, blank=True)
    zd95 = models.DecimalField('所有者权益合计', max_digits=15, decimal_places=5, null=True, blank=True)
    zd96 = models.DecimalField('负债及股东权益总计', max_digits=15, decimal_places=5, null=True, blank=True)
    zd97 = models.DecimalField('营业总收入', max_digits=15, decimal_places=5, null=True, blank=True)
    zd98 = models.DecimalField('营业收入', max_digits=15, decimal_places=5, null=True, blank=True)
    zd99 = models.DecimalField('利息收入', max_digits=15, decimal_places=5, null=True, blank=True)
    zd100 = models.DecimalField('已赚保费', max_digits=15, decimal_places=5, null=True, blank=True)
    zd101 = models.DecimalField('手续费及佣金收入', max_digits=15, decimal_places=5, null=True, blank=True)
    zd102 = models.DecimalField('营业总成本', max_digits=15, decimal_places=5, null=True, blank=True)
    zd103 = models.DecimalField('营业成本', max_digits=15, decimal_places=5, null=True, blank=True)
    zd104 = models.DecimalField('利息支出', max_digits=15, decimal_places=5, null=True, blank=True)
    zd105 = models.DecimalField('手续费及佣金支出', max_digits=15, decimal_places=5, null=True, blank=True)
    zd106 = models.DecimalField('营业税金及附加', max_digits=15, decimal_places=5, null=True, blank=True)
    zd107 = models.DecimalField('销售费用', max_digits=15, decimal_places=5, null=True, blank=True)
    zd108 = models.DecimalField('管理费用', max_digits=15, decimal_places=5, null=True, blank=True)
    zd109 = models.DecimalField('财务费用', max_digits=15, decimal_places=5, null=True, blank=True)
    zd110 = models.DecimalField('资产减值损失', max_digits=15, decimal_places=5, null=True, blank=True)
    zd111 = models.DecimalField('退保金', max_digits=15, decimal_places=5, null=True, blank=True)
    zd112 = models.DecimalField('赔付支出净额', max_digits=15, decimal_places=5, null=True, blank=True)
    zd113 = models.DecimalField('提取保险责任准备金', max_digits=15, decimal_places=5, null=True, blank=True)
    zd114 = models.DecimalField('保单红利支出', max_digits=15, decimal_places=5, null=True, blank=True)
    zd115 = models.DecimalField('分保费用', max_digits=15, decimal_places=5, null=True, blank=True)
    zd116 = models.DecimalField('公允价值变动净收益', max_digits=15, decimal_places=5, null=True, blank=True)
    zd117 = models.DecimalField('投资净收益', max_digits=15, decimal_places=5, null=True, blank=True)
    zd118 = models.DecimalField('对联营企业和合营企业的投资收益', max_digits=15, decimal_places=5, null=True, blank=True)
    zd119 = models.DecimalField('汇兑净收益', max_digits=15, decimal_places=5, null=True, blank=True)
    zd120 = models.DecimalField('营业利润', max_digits=15, decimal_places=5, null=True, blank=True)
    zd121 = models.DecimalField('营业外收入', max_digits=15, decimal_places=5, null=True, blank=True)
    zd122 = models.DecimalField('营业外支出', max_digits=15, decimal_places=5, null=True, blank=True)
    zd123 = models.DecimalField('非流动资产处置净损失', max_digits=15, decimal_places=5, null=True, blank=True)
    zd124 = models.DecimalField('利润总额', max_digits=15, decimal_places=5, null=True, blank=True)
    zd125 = models.DecimalField('所得税', max_digits=15, decimal_places=5, null=True, blank=True)
    zd126 = models.DecimalField('未确认的投资损失.1', max_digits=15, decimal_places=5, null=True, blank=True)
    zd127 = models.DecimalField('净利润', max_digits=15, decimal_places=5, null=True, blank=True)
    zd128 = models.DecimalField('少数股东损益', max_digits=15, decimal_places=5, null=True, blank=True)
    zd129 = models.DecimalField('归属母公司股东的净利润', max_digits=15, decimal_places=5, null=True, blank=True)
    zd130 = models.DecimalField('基本每股收益', max_digits=15, decimal_places=5, null=True, blank=True)
    zd131 = models.DecimalField('稀释每股收益', max_digits=15, decimal_places=5, null=True, blank=True)
    zd132 = models.DecimalField('其他综合收益.1', max_digits=15, decimal_places=5, null=True, blank=True)
    zd133 = models.DecimalField('综合收益总额', max_digits=15, decimal_places=5, null=True, blank=True)
    zd134 = models.DecimalField('归属于少数股东的综合收益总额', max_digits=15, decimal_places=5, null=True, blank=True)
    zd135 = models.DecimalField('归属于母公司普通股东综合收益总额', max_digits=15, decimal_places=5, null=True, blank=True)
    zd136 = models.DecimalField('销售商品、提供劳务收到的现金', max_digits=15, decimal_places=5, null=True, blank=True)
    zd137 = models.DecimalField('收到的税费返还', max_digits=15, decimal_places=5, null=True, blank=True)
    zd138 = models.DecimalField('收到其他与经营活动有关的现金', max_digits=15, decimal_places=5, null=True, blank=True)
    zd139 = models.DecimalField('保户储金净增加额', max_digits=15, decimal_places=5, null=True, blank=True)
    zd140 = models.DecimalField('客户存款和同业存放款项净增加额', max_digits=15, decimal_places=5, null=True, blank=True)
    zd141 = models.DecimalField('向中央银行借款净增加额', max_digits=15, decimal_places=5, null=True, blank=True)
    zd142 = models.DecimalField('向其他金融机构拆入资金净增加额', max_digits=15, decimal_places=5, null=True, blank=True)
    zd143 = models.DecimalField('收取利息和手续费净增加额', max_digits=15, decimal_places=5, null=True, blank=True)
    zd144 = models.DecimalField('收到的原保险合同保费取得的现金', max_digits=15, decimal_places=5, null=True, blank=True)
    zd145 = models.DecimalField('收到的再保业务现金净额', max_digits=15, decimal_places=5, null=True, blank=True)
    zd146 = models.DecimalField('处置交易性金融资产净增加额', max_digits=15, decimal_places=5, null=True, blank=True)
    zd147 = models.DecimalField('拆入资金净增加额', max_digits=15, decimal_places=5, null=True, blank=True)
    zd148 = models.DecimalField('回购业务资金净增加额', max_digits=15, decimal_places=5, null=True, blank=True)
    zd149 = models.DecimalField('经营活动现金流入小计', max_digits=15, decimal_places=5, null=True, blank=True)
    zd150 = models.DecimalField('购买商品、接受劳务支付的现金', max_digits=15, decimal_places=5, null=True, blank=True)
    zd151 = models.DecimalField('支付给职工以及为职工支付的现金', max_digits=15, decimal_places=5, null=True, blank=True)
    zd152 = models.DecimalField('支付的各项税费', max_digits=15, decimal_places=5, null=True, blank=True)
    zd153 = models.DecimalField('支付其他与经营活动有关的现金', max_digits=15, decimal_places=5, null=True, blank=True)
    zd154 = models.DecimalField('客户贷款及垫款净增加额', max_digits=15, decimal_places=5, null=True, blank=True)
    zd155 = models.DecimalField('存放央行和同业款项净增加额', max_digits=15, decimal_places=5, null=True, blank=True)
    zd156 = models.DecimalField('支付原保险合同赔付款项的现金', max_digits=15, decimal_places=5, null=True, blank=True)
    zd157 = models.DecimalField('支付手续费的现金', max_digits=15, decimal_places=5, null=True, blank=True)
    zd158 = models.DecimalField('支付保单红利的现金', max_digits=15, decimal_places=5, null=True, blank=True)
    zd159 = models.DecimalField('经营活动现金流出小计', max_digits=15, decimal_places=5, null=True, blank=True)
    zd160 = models.DecimalField('经营活动产生的现金流量净额', max_digits=15, decimal_places=5, null=True, blank=True)
    zd161 = models.DecimalField('收回投资收到的现金', max_digits=15, decimal_places=5, null=True, blank=True)
    zd162 = models.DecimalField('取得投资收益收到的现金', max_digits=15, decimal_places=5, null=True, blank=True)
    zd163 = models.DecimalField('处置固定资产、无形资产和其他长期资产收回的现金净额', max_digits=15, decimal_places=5, null=True, blank=True)
    zd164 = models.DecimalField('处置子公司及其他营业单位收到的现金净额', max_digits=15, decimal_places=5, null=True, blank=True)
    zd165 = models.DecimalField('收到其他与投资活动有关的现金', max_digits=15, decimal_places=5, null=True, blank=True)
    zd166 = models.DecimalField('投资活动现金流入小计', max_digits=15, decimal_places=5, null=True, blank=True)
    zd167 = models.DecimalField('购建固定资产、无形资产和其他长期资产支付的现金', max_digits=15, decimal_places=5, null=True, blank=True)
    zd168 = models.DecimalField('投资支付的现金', max_digits=15, decimal_places=5, null=True, blank=True)
    zd169 = models.DecimalField('取得子公司及其他营业单位支付的现金净额', max_digits=15, decimal_places=5, null=True, blank=True)
    zd170 = models.DecimalField('支付其他与投资活动有关的现金', max_digits=15, decimal_places=5, null=True, blank=True)
    zd171 = models.DecimalField('投资活动现金流出小计', max_digits=15, decimal_places=5, null=True, blank=True)
    zd172 = models.DecimalField('投资活动产生的现金流量净额', max_digits=15, decimal_places=5, null=True, blank=True)
    zd173 = models.DecimalField('吸收投资收到的现金', max_digits=15, decimal_places=5, null=True, blank=True)
    zd174 = models.DecimalField('子公司吸收少数股东投资收到的现金', max_digits=15, decimal_places=5, null=True, blank=True)
    zd175 = models.DecimalField('取得借款收到的现金', max_digits=15, decimal_places=5, null=True, blank=True)
    zd176 = models.DecimalField('收到其他与筹资活动有关的现金', max_digits=15, decimal_places=5, null=True, blank=True)
    zd177 = models.DecimalField('发行债券收到的现金', max_digits=15, decimal_places=5, null=True, blank=True)
    zd178 = models.DecimalField('筹资活动现金流入小计', max_digits=15, decimal_places=5, null=True, blank=True)
    zd179 = models.DecimalField('偿还债务支付的现金', max_digits=15, decimal_places=5, null=True, blank=True)
    zd180 = models.DecimalField('分配股利、利润或偿付利息支付的现金', max_digits=15, decimal_places=5, null=True, blank=True)
    zd181 = models.DecimalField('子公司支付给少数股东的股利、利润', max_digits=15, decimal_places=5, null=True, blank=True)
    zd182 = models.DecimalField('支付其他与筹资活动有关的现金', max_digits=15, decimal_places=5, null=True, blank=True)
    zd183 = models.DecimalField('筹资活动现金流出小计', max_digits=15, decimal_places=5, null=True, blank=True)
    zd184 = models.DecimalField('筹资活动产生的现金流量净额', max_digits=15, decimal_places=5, null=True, blank=True)
    zd185 = models.DecimalField('汇率变动对现金的影响', max_digits=15, decimal_places=5, null=True, blank=True)
    zd186 = models.DecimalField('现金及现金等价物净增加额', max_digits=15, decimal_places=5, null=True, blank=True)
    zd187 = models.DecimalField('期初现金及现金等价物余额', max_digits=15, decimal_places=5, null=True, blank=True)
    zd188 = models.DecimalField('期末现金及现金等价物余额', max_digits=15, decimal_places=5, null=True, blank=True)

    class Meta:
        verbose_name = '新三板财务'
        verbose_name_plural = '新三板财务'
        db_table = 'listed_xinsan'

    def __unicode__(self):
        return u'%s的新三板财务' % self.entid


#########################################################
############### 扩展企业数据 ################################
#########################################################

# 组织机构代码信息
class ELNacao(ELBaseModel):
    ENTNAME = models.CharField('企业名称', null=True, max_length=200, db_index=True)
    REGNO = models.CharField('工商注册号', null=True, blank=True, max_length=30, db_index=True)
    NACAOID = models.CharField('组织机构代码', null=True, blank=True, max_length=20, db_index=True)
    UNISCID = models.CharField('统一社会信用代码', null=True, blank=True, max_length=30)
    NAME = models.CharField('负责人', null=True, blank=True, max_length=100)

    class Meta:
        verbose_name = '组织机构代码'
        verbose_name_plural = '组织机构代码'
        db_table = 'company_nacao'

    def __unicode__(self):
        return u'%s' % self.ENTNAME
